  <!DOCTYPE html>
  <html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../../lib/layui-v2.8.12/src/layui.js"></script>
    <link rel="stylesheet" href="../../lib/layui-v2.8.12/src/css/layui.css">
    <link rel="stylesheet" href="../../css/team/addTeam.css">
    <script src="../../utils/form-serialize.js"></script>
    <script src="../../lib/axios/axios.min.js"></script>
  </head>

  <body>

  </body>

  </html>
  <?php
  DEFINE('DB_USER', 'worldcup');
  DEFINE('DB_PASSWORD', '123456');
  DEFINE('DB_HOST', 'localhost');
  DEFINE('DB_NAME', 'worldcup');

  $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  if (!$dbc) {
    die('Could not to connect to Mysql:' . mysqli_connect_error());
  }
  mysqli_set_charset($dbc, 'utf8');
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $userName = $_POST['userName'];
    $userPassword = $_POST['userPassword'];
    $nikeName = $_POST['nikeName'];
    $teamId = $_POST['teamId'];
    $gender = $_POST['gender'];
    $birthday = $_POST['birthday'];
    $age = $_POST['age'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $userId = $_GET['userId'];

    $sqlUpdate = "update user set user_name='{$userName}',user_password='{$userPassword}',nike_name='{$nikeName}',vote_team=$teamId,gender=$gender,birthday='{$birthday}',age=$age,phone='{$phone}',address='{$address}' where user_id=$userId;";

    $resUpdate = mysqli_query($dbc, $sqlUpdate);
    if (!$resUpdate) {
      printf("Error: %s\n", mysqli_error($dbc));
      exit();
    }
    // echo $resUpdate;
    echo '<script>';
    if ($resUpdate == 1) {
      echo '
        layui.use(\'layer\', function() {
          var layer = layui.layer;
          layer.msg(\'修改用户成功，请刷新页面\');
          setTimeout(() => {
            var index = parent.layer.getFrameIndex(window.name); // 获取弹出层索引
            parent.layer.close(index); // 关闭弹出层
          }, 2000);
        });
      ';
    } else {
      echo '
        layui.use(\'layer\', function() {
          var layer = layui.layer;
          layer.msg(\'修改用户失败\');
          setTimeout(() => {
            var index = parent.layer.getFrameIndex(window.name); // 获取弹出层索引
            parent.layer.close(index); // 关闭弹出层
          }, 2000);
        });
      ';
    }
    echo '</script>';
  }
  ?>